package Basic;

import Util.Util;

public class AStar2 extends AStar {

	private int weight;

	public AStar2(SecurityTiles tiles) {
		super(tiles);

		this.weight = 5;
	}

	/**
	 * Calcula a distancia euclideana entre dois pontos
	 * 
	 * @param pSource
	 * @param pGoal
	 * @return A distancia euclideana entre p1 e p2
	 */
	@Override
	public int euclidean(int pSource, int pGoal) {
		int ret;

		SecurityTiles securityTiles = (SecurityTiles) tiles;
		int pSourceX = Util.getX(pSource);
		int pSourceY = Util.getY(pSource);
		ret = Math.abs(pSourceX - Util.getX(pGoal) + Math.abs(pSourceY - Util.getY(pGoal)));
		ret = ret - this.weight * securityTiles.getByPosition(pSourceX, pSourceY);

		return ret;
	}
}
